$(function () {
	$('.mapcontainer .mapshow').eq(1).hide();
	$('.tztb-detail-content .detail').hide();
	$('.tztb-detail-content .add').hide();
	//获取日期
	// laydate.render({
	// 	elem: '#mapdatetime', //指定元素
	// 	value: new Date(),
	// 	isInitValue: true,
	// 	done: function () {
	// 		$('.maplrlc-change .map-active').click();
	// 	}
	// });
	jeDate("#mapdatetime",{
		format: "YYYY-MM-DD",
		isinitVal:true,
		initDate:[{DD:"-1"},true],
		donefun:function(obj){
			$('.maplrlc-change .map-active').click();
			myAjax(basic + `/qbfx/MapStatics/${$('#mapdatetime').val()}`, function (result) {
				chartTypeChongqing(echartscq, result.msg);
				top5DataShow(result.msg);
			});
		}
    });
	$('.rsrc').on('click', 'dd', function () {
		$(this).addClass('rsrcactive').siblings().removeClass('rsrcactive');
		if ($(this).index() == 0) {
			$('.hdrs-container > div').css('margin-left', '0');
		} else {
			$('.hdrs-container > div').css('margin-left', '-100%');
		}
	});
	getUserInfo();
	loadSystemMenu();
	showNav();
	loadData();
	upload();
	$('.header-exit').click(function () {
		systemExit();
	});
});
var echartsryds = document.getElementById('ryds');
var echartsjrhdrs = document.getElementById('jrhdrs');
var echartsjrhdrc = document.getElementById('jrhdrc');
var echartshdry = document.getElementById('hdry');
var echartsxs = document.getElementById('echarts-xs');
var echartsmap = document.getElementById('chinamap');
var echartscq = document.getElementById('cqmap');
var echartscqtop5 = document.getElementById('cqtop5');
var navsenddata = {};
var chart;
var cqchart;
var pagenow = 1;
var filePath = '';

//请求参数
// var reqData = {
// 	map:function(){
// 		return {'time':$('#mapdatetime').val()};
// 	}
// };
//ajax方法
var myAjax = function (url, fun) {
	$.ajax({
		url: url,
		type: 'get',
		contentType: 'application/json',
		dataType: 'json',
		success: function (data) {
			// fun(data);
			if (data.success == true) {
				fun(data);
			} else {
				//  window.location.href= basic +"/login/userlogin";
			}
		},
		error: function () {
			console.log('error');
		}
	});
}
//加载数据
var loadData = function () {
	//left
	myAjax(basic + '/qbfx/indexStatic', function (result) {
		//左上
		var result = result.msg;
		$('.left-basic .influx').html(result.lrrs);
		$('.left-basic .outflow').html(result.lcrs);
		$('.left-basic .firsttoyu').html(result.scly);
		$('.left-basic .rails').html(result.sgrs);
		//人员底数
		console.log(result.jrhdrs);
		chartTypeBar(echartsryds, result.ryds.name, result.ryds.value, 'portrait', {
			normal: {
				color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
					offset: 0,
					color: 'rgb(0,251,224)'
				}, {
					offset: 1,
					color: 'rgb(24,184,119)'
				}]),
				opacity: 1,
			}
		});
		//今日活动人数
		chartTypeBar(echartsjrhdrs, result.jrhdrs.name, result.jrhdrs.value, 'portrait', {
			normal: {
				color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
					offset: 0,
					color: 'rgb(0,219,251)'
				}, {
					offset: 1,
					color: 'rgb(35,83,220)'
				}]),
				opacity: 1,
			}
		});
		//今日活动人次
		chartTypeBar(echartsjrhdrc, result.jrhdrc.name, result.jrhdrc.value, 'portrait', {
			normal: {
				color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
					offset: 0,
					color: 'rgb(0,219,251)'
				}, {
					offset: 1,
					color: 'rgb(35,83,220)'
				}]),
				opacity: 1,
			}
		});
	});
	// 流入流出切换
	$('.maplrlc-change').on('click', 'span', function () {
		var $type = $(this).data('type');
		$(this).addClass('map-active').siblings().removeClass('map-active');
		console.log($('#mapdatetime').val());
		//中国地图
		myAjax(basic + `/qbfx/inout/${$type}/${$('#mapdatetime').val()}`, function (result) {
			chartTypeChina(echartsmap,result.msg,$type);
		});
	})
	$('.maplrlc-change .map-active').click();
		//中国地图重庆地图切换
		$('.map-change > li').on('click', function () {
			var index = $(this).index();
			console.log('index');
			console.log(index);
			$(this).addClass('active').siblings().removeClass('active');
			$('.mapcontainer .mapshow').eq(index).show().siblings().hide();
			$('.map-change').show();
			cqchart.resize();
			chart.resize();
		});
		//重庆地图加载
		myAjax(basic + `/qbfx/MapStatics/${$('#mapdatetime').val()}`, function (result) {
			chartTypeChongqing(echartscq, result.msg);
			top5DataShow(result.msg);
		});
	//折线图
	$('#linetime').change(function(){
		myAjax(basic + `/qbfx/zhexian/${$('#linetime').val()}`, function (result) {
			// console.log(result);
			var result = result.msg;
			chartTypeLine(echartshdry, result.name, result.value);
		});
	});
	$('#linetime').change();
	//饼图
	// myAjax(basic + `/qbfx/zhexian/${$('#linetime').val()}`, function (data) {
	// 	console.log(result)
	// 	chartTypePie(echartsxs, data);
	// });

	//指令流转
	myAjax(basic + '/homezltj/zllztj', function(result) {
		var obj = {};
		$.each(result.msg,function(key,value){
			var arr = [0,0,0,0];
			$.each(value,function(i,item){
				$.each(item,function(a,b){
					arr[Number(a)] += b;
				});
			});
			obj[key] = arr;
		});
		$('.li-bjhc span').each(function(i){
			$(this).html(zllzdealData(obj.bjhczl[i])).attr('title',obj.bjhczl[i]);
		});
		$('.li-sjhc span').each(function(i){
			$(this).html(zllzdealData(obj.test_sijian[i])).attr('title',obj.test_sijian[i]);
		});
		$('.li-bjyp span').each(function(i){
			$(this).html(zllzdealData(obj.bjypzlProcess[i])).attr('title',obj.bjypzlProcess[i]);
		});
		$('.li-tzzl span').each(function(i){
			$(this).html(zllzdealData(obj.tzzl[i])).attr('title',obj.tzzl[i]);
		})
	});
	loadTable();
	//点击更多出弹窗
	$('.tzmore').on('click', function () {
		$('.wrap-container-basic').css('display', 'block');
	});
	//关闭弹窗
	$('.tc-close').on('click', function () {
		var type = $(this).data('type');
		$('.wrap-container-' + type).css('display', 'none');
	});
	//点击增加
	$('.tztb-add').on('click', function () {
		$('.tztb-detail-content .add').show();
		$('.tztb-detail-content .detail').hide();
		$('.wrap-container-detail').css('display', 'block');
		$('.wrap-container-detail .bt').val('');
		$('.wrap-container-detail .content').val('');
	});
	//点击通体通报标题出具体内容
	$('.tzlist').on('click','tbody tr',function(){
		$(this).addClass('read').removeClass('unread');
		var $trdata = $(this).data('rows');
		console.log($trdata);
		$('.tztb-detail-content .detail').show();
		$('.tztb-detail-content .add').hide();
		$('.wrap-container-detail').css('display', 'block');
		$('.wrap-container-detail .bt').val($trdata.bt);
		$('.wrap-container-detail .content').val($trdata.content);
		if($trdata.filename){
			$('.wrap-container-detail .download').css('display','block');
			$('.wrap-container-detail .download').attr('href',basic + '/qbfx/downloadFile?id=' + $trdata.id);
		}
	});
	//点击取消
	$('.form-off').on('click',function(){
		var type = $(this).data('type');
		$('.wrap-container-' + type).css('display', 'none');
	});
	//点击增加提交
	$('#add-submit').on('click',function(){
		var type = $(this).data('type');
		addnewTztb();
		$('.wrap-container-' + type).css('display', 'none');
	})
}
//导航栏显示隐藏
var showNav = function () {
	$('.header-app .onemenu').hover(function () {
		$(this).find(".twomenu").css("display", "block");
	}, function () {
		$(this).find(".twomenu").css("display", "none");
	});

}
//加载系统菜单
var loadSystemMenu = function () {
	var params = new Object();
	//发送请求，获取数据
	$.ajax({
		url: basic + "/system/queryUserQX.do",
		type: "POST",
		data: params,
		async: false,
		success: function (result) {
			var success = result.success;
			var show = true;
			if (success == true) {
				var content = result.content;
				if (content != undefined && content.length > 0) {
					showSystemMenu(content);
				} else {
					show = false;
				}
			} else {
				show = false;
			}
			if (show == false) {
				window.location.href = basic + "/login/userlogin";
			}

		},
		error: function (XHR) {
			console.log(XHR)

		}
	});
}
/** 
//初始化系统菜单
var showSystemMenu = function (content) {
	var yjMenu_htm = ""; //总导航栏
	var dzdaMenu_htm = "";//电子档案导航栏
	var fkywMenu_htm = "";//反恐业务导航栏
	var fxypMenu_htm = "";//分析研判导航栏
	var xtglMenu_htm = "";//系统管理导航栏

	//电子档案
	if (("," + content + ",").indexOf(",FK_yyzx_dzda,") > -1) {
		yjMenu_htm += '<li  class="onemenu">' +
			'<span class="img-logo menu-dzda"></span>' +
			'<span class="">电子档案</span>' +
			'<ul class="twomenu" id="dzda-menu">';
		if (("," + content + ",").indexOf(",FK_gzrydzda_cq,") > -1) {
			dzdaMenu_htm += '<a onclick="goToUrl(\'gjjc\')"><li>关注人员电子档案</li></a>';
		}
		yjMenu_htm += '</ul>' +
			'</li>';
	}
	//反恐业务
	if (("," + content + ",").indexOf(",FK_fkyw_cq,") > -1) {
		yjMenu_htm += '<li  class="onemenu">' +
			'<span class="img-logo menu-fkyw"></span>' +
			'<span class="">反恐业务</span>' +
			'<ul class="twomenu" id="fkyw-menu">';
		if (("," + content + ",").indexOf(",FK_zllzglxt_cq,") > -1) {
			fkywMenu_htm += '<a onclick="goToUrl(\'dzda\')"><li>指令流转管理系统</li></a>';
		}
		if (("," + content + ",").indexOf(",FK_gzrydzda_cq,") > -1) {
			fkywMenu_htm += '<a onclick="goToUrl(\'gjjc\')"><li>信息反馈</li></a>';
		}
		yjMenu_htm += '</ul>' +
			'</li>';
	}
	//系统管理
	if (("," + content + ",").indexOf(",FK_xtgl,") > -1) {
		yjMenu_htm += '<li  class="onemenu">' +
			'<span class="img-logo menu-yygl"></span>' +
			'<span class="">系统管理</span>' +
			'<ul class="twomenu" id="xtgl-menu">';
		if (("," + content + ",").indexOf(",FK_xtgl_FK_portals_maintain,") > -1) {
			xtglMenu_htm += '<a onclick="goToUrl(\'qxgl\')"><li>权限管理</li></a>';
		}
		yjMenu_htm += '</ul>' +
			'</li>';
	}
	$("#all-menu").html(yjMenu_htm);
	$("#dzda-menu").html(dzdaMenu_htm);
	$("#fkyw-menu").html(fkywMenu_htm);
	$("#xtgl-menu").html(xtglMenu_htm);
}

//链接跳转
var goToUrl = function (url) {

	if (url == 'dzda' || 		//电子档案
		url == 'gjjc' || 		//轨迹监测
		url == 'xshc' || 		//线索核查
		url == 'qxgl' || 		//权限管理
		url == 'aqsj' ||		//安全审计
		url == 'txyp' ||
		url == 'zdzd' ||
		url == 'test'
		//图析研判
		//TODO 在此加入新的地址
	) {
		// console.log(navsenddata);
		// jumppage(urlObj[url], navsenddata, '_blank');
		// $("#turform").attr("action",urlObj[url]).submit();

	}
	jumppage(urlObj[url], navsenddata, '_blank');
}
*/
//获取用户信息
var getUserInfo = function () {
	$.ajax({
		url: basic + "/login/loadUserInfo",
		type: "POST",
		data: {},
		async: false,
		success: function (result) {
			var data = result.user;
			navsenddata = { 'sessionid': result.sessionid, 'sfzh': data.user_sfzh, 'username': data.user_sfzh, 'zzjgmc': data.user_zzjgmc };
			$('.user-name').text(result.user.user_username);
		}
	});
}
// 指令流转处理数据
var zllzdealData = function(data){
	var a = Math.floor(data/10000);
	var b = data % 10000;
	if(a >= 1 && b != 0){
		return a + 'w+';
	}else if(a >= 1 && b == 0){
		return a + 'w';
	}else{
		return data;
	}
}
//增加通知通报的方法
var addnewTztb = function(){
	var data = {
		'bt':$('.wrap-container-detail .bt').val(),
		'content':$('.wrap-container-detail .content').val(),
		'filename':filePath
	}
	$.ajax({
		url: basic + '/tztg/addOrUpdateTztg',
		type: 'post',
		// contentType: 'application/json',
		dataType: 'json',
		data:data,
		success: function(result){
			if (result.success == true) {
				loadTable();
			} else {
				//  window.location.href= basic +"/login/userlogin";
			}
		},
		error: function(){
			console.log('error');
		}
	})
}
//上传
var upload = function(){
	layui.upload.render({
		elem: '.upload',
		url: basic + '/qbfx/updateFile',
		multiple: false,
		accept: 'file',
		before: function(obj){   
		  var files = this.files = obj.pushFile(); //将每次选择的文件追加到文件队列           
		  obj.preview(function(index, file, result){
			var tr = file.name;  
			$(".uploadvalue").val(tr);
		  });
		 
		},
		done: function(result){
			filePath = result.msg.filePath;
		}
	});
}
//加载弹窗表格数据
var loadTable = function(){
	myAjax(basic + `/tztg/queryTztgOfPage?currentPage=${pagenow}&pageSize=10`, function(result) {
		if(pagenow == 1){
			var tbody = $('.tzlist tbody').html('');
			$.each(result.content, function (i, item) {
				if(i < 5){
				item.lrsj = item.lrsj.split(' ')[0];
				var tr = ` <tr class="unread">
								<td><label></label>${item.bt}</td>
								<td>${item.lrsj}</td>
							</tr>`;
				var $tr = $(tr).data('rows',item);
				tbody.append($tr);
				}
			});
		}
		$('.totalData_page').html(result.totalPage);
		$('.totalData_num').html(result.totalSize);
		var tztbtbody = $('.tztbt-table-detail tbody').html('');
		$.each(result.content, function (i, item) {
			item.lrsj = item.lrsj.split(' ')[0];
			var tr = ` <tr class="unread">
							<td><label></label>${item.bt}</td>
							<td>${item.lrsj}</td>
						</tr>`;
			var $tr = $(tr).data('rows',item);
			tztbtbody.append($tr);
		})
		page(result.totalPage);
	});
}
//退出系统
var systemExit = function () {
	swal({
		title: "您确定要退出登录吗？",
		type: "warning",
		closeOnConfirm: false,
		showCancelButton: true,
		confirmButtonColor: "#DD6B55",
		confirmButtonText: "确定",
		cancelButtonText: "取消"
	}, function () {
		window.location.href = basic + '/login/logout';
	});
}
//柱形图
var chartTypeBar = function ($node, namedata, valuedata, AXIS, itemStyle) {
	$($node).html('');
	$($node).removeAttr('_echarts_instance_');
	var echartsBar = echarts.init($node);
	var XAxis = [{
		type: 'category',
		data: namedata,
		axisLine: {
			show: true,
			lineStyle: {
				color: "#476586",
				width: 1,
				type: "solid"
			}
		},
		axisTick: {
			show: false
		},
		axisLabel: {
			interval: 0,
			// rotate:-30,
			show: true,
			textStyle: {
				color: "#fff",
			}
		}
	}];
	var YAxis = [{
		type: 'value',
		axisLabel: {
			textStyle: {
				color: "#fff",
			}
		},
		axisLine: {
			show: true,
			lineStyle: {
				color: "#476586",
				width: 1,
				type: "solid"
			},
		},
		axisTick: {
			show: false
		},
		splitLine: {
			show: false
		}
	}];
	if (AXIS == "transverse") {//判断条形图是横向还是纵向
		var temp;
		temp = XAxis;
		XAxis = YAxis;
		YAxis = temp;
	}
	var option = {
		tooltip: {
			trigger: 'item',
		},
		grid: {
			left: '4%',
			right: '4%',
			bottom: '3%',
			top: '6%',
			containLabel: true
		},
		xAxis: XAxis,
		yAxis: YAxis,
		series: [{
			type: 'bar',
			data: valuedata,
			barWidth: 20, //柱子宽度
			barGap: 2, //柱子之间间距
			itemStyle: itemStyle
		}]
	};
	echartsBar.setOption(option);
}
//折线图
var chartTypeLine = function ($node, namedata, valuedata) {
	$($node).html('');
	$($node).removeAttr('_echarts_instance_');
	var echartsLine = echarts.init($node);
	var axislabel = {
				show: true,
				interval: 0,
				textStyle: {
					color: "#fff",
				}
			};
	if(namedata.length > 13){
		axislabel = {
			show: true,
			interval: 0,
			rotate:-30,
			textStyle: {
				color: "#fff",
				fontSize:12
			}
		};
	}
	var option = {
		tooltip: {
			show:true,
			trigger: 'axis',
		},
		grid: {
			left: '1%',
			right: '3%',
			bottom: '10%',
			top: '16%',
			containLabel: true
		},
		xAxis: [{
			type: 'category',
			axisLine: {
				show: true,
				lineStyle: {
					color: "#476586",
					width: 1,
					type: "solid"
				}
			},
			axisTick: {
				show: false
			},
			axisLabel: axislabel,
			data: namedata
		}],
		yAxis: [{
			type: 'value',
			axisLabel: {
				textStyle: {
					color: "#fff",
				}
			},
			axisLine: {
				show: true,
				lineStyle: {
					color: "#476586",
					width: 1,
					type: "solid"
				},
			},
			axisTick: {
				show: false
			},
			splitLine: {
				show: false
			}
		}],
		series: [{
			type: 'line',
			smooth: true,
			symbol: 'circle',
			lineStyle: {
				normal: {
					width: 1
				}
			},
			areaStyle: {
				normal: {
					color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
						offset: 0,
						color: 'rgba(85, 225, 157, 0.5)'
					}, {
						offset: 0.8,
						color: 'rgba(85, 225, 157, 0.1)'
					}], false),
					shadowColor: 'rgba(0, 0, 0, 0.1)',
					shadowBlur: 10
				}
			},
			itemStyle: {
				normal: {
					color: 'rgb(85, 225, 157)'
				}
			},
			data: valuedata
		}]
	};
	echartsLine.setOption(option);
}
// 饼状图
var chartTypePie = function ($node, value) {
	$($node).html('');
	$($node).removeAttr('_echarts_instance_');
	var echartsPie = echarts.init($node);
	var option = {
		tooltip: {
			trigger: 'item',
			formatter: "{a} <br/>{b} : {c} ({d}%)"
		},
		series: [
			{
				type: 'pie',
				radius: '70%',
				center: ['50%', '50%'],
				color: ['rgb(28,92,185)', 'rgb(44,117,200', 'rgb(44,160,200)'],
				data: value.sort(function (a, b) { return b.value - a.value }),
				roseType: 'angle',
				label: {
					normal: {
						show: false
					}
				},
				itemStyle: {
					normal: {
						shadowBlur: 200,
						shadowColor: 'rgba(0, 0, 0, 0.2)'
					}
				}
			}
		]
	};
	echartsPie.setOption(option);
}
//中国地图
var chartTypeChina = function ($node, MapData, lrlcfs) {
	$($node).html('');//清空容器
	$($node).removeAttr("_echarts_instance_");//清除echarts遗留标记
	//echarts中国相关数据
	var data = chinamap;
	echarts.registerMap('china', data);//定义展示位置
	chart = echarts.init($node);//创建chart实例
	var geoCoordMap = {
		'上海': [121.4648, 31.2891],
		'包头': [110.3467, 41.4899],
		'北京': [116.4551, 40.2539],
		'天津': [117.4219, 39.4189],
		'内蒙古': [111.670801, 40.818311],
		'河北': [114.502461, 38.045474],
		"山西": [112.549248, 37.857014],
		"台湾": [121.509062, 25.044332],
		"辽宁": [123.429096, 41.796767],
		"吉林": [125.3245, 43.886841],
		"黑龙江": [126.642464, 45.756967],
		"江苏": [118.767413, 32.041544],
		"浙江": [120.153576, 30.287459],
		"安徽": [117.283042, 31.86119],
		"福建": [119.306239, 26.075302],
		"江西": [115.892151, 28.676493],
		"山东": [117.000923, 36.675807],
		"河南": [113.665412, 34.757975],
		"湖北": [114.298572, 30.584355],
		"湖南": [112.982279, 28.19409],
		"广东": [113.280637, 23.125178],
		"广西": [108.320004, 22.82402],
		"海南": [110.33119, 20.031971],
		"四川": [104.065735, 30.659462],
		"贵州": [106.713478, 26.578343],
		"云南": [102.712251, 25.040609],
		"西藏": [91.132212, 29.660361],
		"陕西": [108.948024, 34.263161],
		"甘肃": [103.823557, 36.058039],
		"青海": [101.778916, 36.623178],
		"宁夏": [106.278179, 38.46637],
		"新疆": [87.617733, 43.792818],
		"重庆": [106.504962, 29.533155],
		"香港": [114.173355, 22.320048],
		"澳门": [113.54909, 22.198951]
	};
	//var planePath = 'path://M1705.06,1318.313v-89.254l-319.9-221.799l0.073-208.063c0.521-84.662-26.629-121.796-63.961-121.491c-37.332-0.305-64.482,36.829-63.961,121.491l0.073,208.063l-319.9,221.799v89.254l330.343-157.288l12.238,241.308l-134.449,92.931l0.531,42.034l175.125-42.917l175.125,42.917l0.531-42.034l-134.449-92.931l12.238-241.308L1705.06,1318.313z';
	var convertData = function (data) {//准备echarts画流向图需要的数据格式
		var res = [];
		for (var i = 0; i < data.length; i++) {
			var dataItem = data[i];
			var fromCoord = geoCoordMap[dataItem[0].name];
			var toCoord = geoCoordMap[dataItem[1].name];
			if (fromCoord && toCoord) {
				if (lrlcfs == '0') {
					res.push({
						fromName: dataItem[0].name,
						toName: dataItem[1].name,
						coords: [fromCoord, toCoord],
						code: dataItem[0].code
					});
				} else if (lrlcfs == '1') {
					res.push({
						fromName: dataItem[0].name,
						toName: dataItem[1].name,
						coords: [toCoord, fromCoord],
						code: dataItem[0].code
					});
				}

			}
		}
		return res;
	};
	var color = ['#fff'];//地图整体色值
	var series = [];//存储流动节点、点间弧线配置信息的数组
	[['重庆', MapData]].forEach(function (item, i) {//可允许多个地点交错流动
		series.push({
			name: item[0].name + item[0].value,
			type: 'lines',
			zlevel: 1,
			effect: {
				show: true,
				period: 4,
				trailLength: 0.9,
				color: 'rgb(125,224,226)',
				symbolSize: 4
			},
			lineStyle: {
				normal: {
					color: 'color[i]',
					width: 0,
					curveness: 0.2
				}
			},
			data: convertData(item[1])
		},
			{
				name: item[0].name + item[0].value,
				type: 'lines',
				zlevel: 2,
				symbol: ['circle', 'circle'],
				symbolSize: 10,
				lineStyle: {
					normal: {
						color: 'rgb(125,224,226)',
						width: 2,
						curveness: 0.2,
						shadowColor: 'rgba(255, 255,255, 0.5)',
						shadowBlur: 10
					}
				},
				data: convertData(item[1])
			},
			{
				name: item[0].name,
				type: 'effectScatter',
				coordinateSystem: 'geo',
				zlevel: 2,
				rippleEffect: {
					brushType: 'stroke'
				},
				symbolSize: function (val) {
					return val[1] / 2;
				},
				itemStyle: {
					normal: {
						color: 'rgb(125,224,226)',
						opacity: '0.6'
					}
				},
				data: item[1].filter(
					//dataItem => geoCoordMap[dataItem[0].name]
					function (dataItem) {
						return geoCoordMap[dataItem[0].name];
					}
				).map(function (dataItem) {
					return {
						name: dataItem[0].name,
						value: geoCoordMap[dataItem[0].name].concat([dataItem[0].value]),
						code: dataItem[0].code
					};
				})
			});
	});
	chart.clear();
	chart.setOption({//echarts配置（可查echarts配置）
		tooltip: {
			trigger: 'item',
			formatter: function (a, b, c, d) {
				if (a.data.name) {
					var aaa = a.data.value.toString()
					var bbb = aaa.split(',')[2]
					return a.data.name + ':' + bbb;
				} 
			}
		},
		geo: {
			map: 'china',
			label: {
				normal: {//地图默认展示地名
					show: true,
					color: '#98b6f1'
				},
				emphasis: {
					show: true,
					color: '#98b6f1'
				}
			},
			roam: false,//控制缩放rgba(41,112,207,0.4)
			zoom: 1.2,
			itemStyle: {
				normal: {
					areaColor: 'rgba(25,68,227,0.24)',
					borderColor: 'rgb(83,160,200)',
					shadowColor: 'rgba(83, 160, 200, 1)',
					shadowBlur: 80
				},
				emphasis: {
					areaColor: 'rgba(25,68,227,0.34)',
				}
			}
		},
		series: series
	});
}
//重庆地图
var chartTypeChongqing = function ($node, MapData) {
	$($node).html('');//清空容器
	$($node).removeAttr("_echarts_instance_");//清除echarts遗留标记
	//echarts重庆相关数据
	var data = chongqingmap;
	echarts.registerMap('chongqing', data);//定义展示位置
	cqchart = echarts.init($node);//创建chart实例
	cqchart.setOption({//echarts配置（可查echarts配置）
		tooltip: {
			trigger: 'item',
			// formatter: "{b}:{c}"
			formatter: function (obj, item, fun) {
				var itemData = obj.data;
				return itemData.name + ": " + (itemData.value || "0");
			}
		},
		visualMap: {
			min: 0,
			max: 100,
			left: 'left',
			top: 'bottom',
			text: ['高', '低'],// 文本，默认为数值文本
			calculable: true,
			inRange: {
				color: ['#3b7fb8', '#50a3ba', '#eac736', '#e2644d', '#d94e5d']
			}
		},
		// visualMap: {
		// 	min: 0,
		// 	max: 300,
		// 	splitNumber: 5,
		// 	color: ['#d94e5d','#eac736','#50a3ba'],
		// 	textStyle: {
		// 		color: '#fff'
		// 	}
		// },
		series: [{
			type: 'map',
			map: 'chongqing',
			roam: false,
			zoom: 1.2,
			label: {
				normal: {//地图默认展示地名
					show: true,
					color: '#98b6f1'
				},
				emphasis: {
					show: true,
					color: '#98b6f1'
				}
			},
			itemStyle: {
				normal: {
					areaColor: 'rgba(25,68,227,0.24)',
					borderColor: 'rgb(83,160,200)',
					shadowColor: 'rgba(83, 160, 200, 1)',
					shadowBlur: 80
				},
				emphasis: {
					areaColor: 'rgba(25,68,227,0.34)',
				}
			},
			data: MapData
		}]
	});
}
var top5DataShow = function (mapData) {
	var top5dataname = [];
	var top5datavalue = [];
	var Data = mapData.sort(function (a, b) {
		return b.value - a.value;
	});
	$.each(Data, function (i, item) {
		if (i < 5) {
			top5dataname.push(item.name);
			top5datavalue.push(item.value);
		}
	});
	chartTypeBar(echartscqtop5, top5dataname.reverse(), top5datavalue.reverse(), 'transverse', {
		normal: {
			color: function (params) {
				var colorList = ['#d94e5d', '#e2644d', '#eac736', '#50a3ba', '#3b7fb8'];
				if (params.value < 20) {
					return colorList[4]
				} else if (params.value < 40 && params.value >= 20) {
					return colorList[3]
				} else if (params.value < 60 && params.value >= 40) {
					return colorList[2]
				} else if (params.value < 80 && params.value >= 60) {
					return colorList[1]
				} else if (params.value >= 80) {
					return colorList[0]
				}

			}
		}
	});
}
var page=function(pagenum){
	Page({
		num: pagenum, //页码数
		startnum: pagenow, //指定页码
		elem: $('.pageStyle #page2'), //指定的元素
		callback: function(n) { //回调函数
			pagenow=n;
			loadTable();
		}
	});
};